<!DOCTYPE HTML>
<html lang="utf-8">
<head>
<meta charset="utf-8">
<title>驾车宝典-${loginMember.nickName!}的话题</title>
<link href="${ctx}/styles/group.css" rel="stylesheet" type="text/css">
<link href="${ctx}/styles/userPanel.css" rel="stylesheet" type="text/css">
<#include '/baseHead.ftl'>
<!--主要部分开始-->
<section id="main"><div class="bgA_01">
	
	<div class="userMailPanel_01"><!--这个功能块里的button标签可根据需要在 span button a 三种标签中调换-->
		<div class="menuField">
			<div class="btns">
				<a   href='${ctx}/message/newmessage' class="btn btn1" title="点击撰写站内信">写站内信</a>
			</div>
			<nav class="menu">
				<ul>
					<li><a  title="进入收件箱" href="${ctx}/message/receive" >收件箱</a></li>
					<li><a  class="on"  title="进入发件箱">发件箱</a></li>
					<li></li>
				</ul>
			</nav>   
		</div>
		<div class="listField">
			<div class="info">
				<p>${page.totalCount?c}封站内信 </p>
			</div>
			<div class="list">
				<dl>
					<dt>
						<p class="info1">来自</p>
						<p class="info2">标题</p>
						<p class="info3">时间</p>
					</dt>
					<#list page.result as message>
					<dd>
						<p class="info1"><input type="checkbox" class="check" name="messageId" value="${message.mid?c}"> 
							<a href="<@userCenterLink memberId="${message.fromMemberId}"/>" title="查看用户信息">${message.fromMemberNickName!}</a></p>
						<p class="info2" style="width:382px"><a href="${ctx}/message/detail/${message.mid?c}?from=send" title="点击查看详细">
							<#if message.isRead == 0 ><b></#if>${message.messageTitle!}<#if message.isRead == 0 ></b></#if></a></p>
						<p class="info3" style="width:117px">${message.sendDate?datetime}</p>
					</dd>
					</#list>
				</dl>
			</div>
			<div class="btns">
				<input type="checkbox" class="check" name="checkAll" id="checkAll_01" onclick="checkAll()"> <label for="checkAll_01">全选</label>
				<button class="btn btn1" title="删除" onclick='deleteMessage();'>删除</button>
				<!--<button class="btn btn1" title="标记为已读" onclick='setIsRead();'>标记为已读</button> -->
			</div>
		</div>
		
		<div class="pageNumField">
			<p>
				<#if !page.firstPage>
					<a href="${ctx}/message/receive/${messageType}-${isRead}-1">首页</a>
					</#if>
					<#if page.hasPreviousPage>
					<a href="${ctx}/message/receive/${messageType}-${isRead}-${pageNumber-1}">上一页</a>
					</#if>
					<#list page.getLinkPageNumbers() as item>
						<#if item_index==5> 
							<#break>
						</#if>
						<#if item == page.thisPageNumber>
						<!--/{cityNo}-{cateId}-{filter}-{groupId}-{pageNumber}-{orderBy} -->
							<a href="javascript:;" class="on">${item}</a>
						<#else>
								<a href="${ctx}/message/receive/${messageType}-${isRead}-${item}">${item}</a>
						</#if>
					</#list>
					<#if page.hasNextPage>
					<a href="${ctx}/message/receive/${messageType}-${isRead}-${pageNumber+1}">下一页</a>
					</#if>
					<#if !page.lastPage>
					<a  href="${ctx}/message/receive/${messageType}-${isRead}-${page.lastPageNumber?c}">末页</a>
					</#if>
			</p>
		</div>
	</div>
	
			
<#include '/commonFriendLink.ftl'>

</div></section>
<script>
	var isCheckAll = true;
	function checkAll(){
		var messageIdCheckBoxs= 	document.getElementsByName("messageId");
			var messageIds = "";
			for ( var index = 0 ; index <messageIdCheckBoxs.length;index ++){
				var   messageIdCheckBox = messageIdCheckBoxs[index];
				messageIdCheckBox.checked = isCheckAll ;
			
			}
			if ( isCheckAll ) {
				isCheckAll = false;
			}else{
				isCheckAll = true;
			}
	}
	function getCheckedMessageId(){
		var messageIdCheckBoxs= 	document.getElementsByName("messageId");
		var messageIds = "";
		for ( var index = 0 ; index <messageIdCheckBoxs.length;index ++){
			var   messageIdCheckBox = messageIdCheckBoxs[index];
			if (   messageIdCheckBox.checked ){
			   if ( messageIds == ""){
			   		messageIds = messageIdCheckBox.value ;
			   		
			   }else{
			       messageIds = messageIds +","+ messageIdCheckBox.value;
			   }
			}
		}
		return messageIds;
	}
	function setIsRead(){
		  var checkedMessageIds  = getCheckedMessageId();
		  if ( checkedMessageIds == ""){
		  	
		  	alert("请勾选要操作的消息!");
		  	return ;
		  
		  }
		  if ( confirm("确认标识为已读吗?")){
			  $.ajax({
			 			type: "get",
						url: "${ctx}/message/setisread",
						beforeSend: function(XMLHttpRequest){
						//ShowLoading();
						},
						success: function(data, textStatus){
							window.location.reload();
						},
						data:{
							checkedMessageIds:checkedMessageIds
						},
						dataType:'json'
					}
		 		)
	 	}
	
	}
	function deleteMessage(){
	  var checkedMessageIds  = getCheckedMessageId();
		  if ( checkedMessageIds == ""){
		  	
		  	alert("请勾选要操作的消息!");
		  	return ;
		  
		  }
	    if ( confirm("确认删除消息吗?")){
		$.ajax({
			 			type: "get",
						url: "${ctx}/message/deletereceive",
						beforeSend: function(XMLHttpRequest){
						//ShowLoading();
						},
						success: function(data, textStatus){
								window.location.reload();
						},
						data:{
								checkedMessageIds:checkedMessageIds
						},
						dataType:'json'
					}
		 		)
		}
	}
</script>
<!--主要部分结束-->
<#include '/baseFoot.ftl'>